
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/cglist.css"/>
    <script type="text/javascript" src="/plan/caigou/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/plan/caigou/js/layer.js" ></script>

    <script type="text/javascript" src="/plan/caigou/js/rem.js" ></script>
    <script src="/plan/js/dropload.min.js"></script>

    <title>仓库</title>
</head>
<style>
    .cglist li{border-bottom: 1px solid #f0f0f0;margin-top: 0;}
    .cglist li:last-child{border-bottom: none;}
    .cate_mid{display: block;}
    .text_box .text{width: 97%;}
    .text_box .submit{right: 0;}
    *{
        -webkit-overflow-scrolling: touch;
    }


    .dropload-noData,.dropload-load,.dropload-refresh{
        position: relative;
        margin-top: 0.31rem;
        font-size: 0.22rem;
        width: 1.6rem;
        margin: 0 auto;
        color: grey;
        text-align: center;
    }
    .dropload-noData:after,.dropload-load:after,.dropload-refresh:after {
        content: "";
        position: absolute;
        top: 0.16rem;
        width: 1.01rem;
        height: 1px;
        background-color: #eeeeee;
        right: -1.18rem;
    }

    .dropload-noData:before,.dropload-load:before,.dropload-refresh:before {
        content: "";
        position: absolute;
        top: 0.16rem;
        width: 1.01rem;
        height: 1px;
        background-color: #eeeeee;
        left: -1.2rem;
    }
    .dropload-down{
        display: none;
    }
</style>
<body>
<div class="top">
    <div class="cate_mid">
            <div class="text_box" name="list_search_text_box" onclick="">
                <input id="keyword" name="search" type="text" placeholder="请输入仓库名称或负责人" class="text" value="">
                <input type="button" value="" class="submit" id="list_search_submit">
            </div>
    </div>
</div>
<div class="mescroll">
    <ul class="cglist" id="pro1" style="margin-bottom: 1rem;">



    </ul>
</div>
<a href="add_store.html"><div class="pay">新增</div></a>
<script>
    var jsonData={};
    var meLoad;
    jsonData.counter=1;
    $("#list_search_submit").click(function () {
        jsonData.counter=1;
        if ($("#keyword").val()==''){
            if(jsonData.hasOwnProperty('title')) delete jsonData.title;

        }else{
            jsonData.title = $("#keyword").val();
        }


        overProduct();

    })
    initList();
    //重载产品数据
    function overProduct() {
        layer.open({type: 2,  shadeClose: false});

        $.ajax({
            type:"post",
            url:"/index/store/store_list",
            data:jsonData,
            success:function (data) {
                layer.closeAll()
                if (data.list!=null){
                    jsonData.counter++;
                    let str=getList(data.list);
                    if (data.list.length==0){
                        str='<img style="display: block; width: 2.82rem;margin: 37% auto;" src="/plan/caigou/img/wu.png">';
                    }
                    $("#pro1").html(str);
                    $("#pro1").show();
                    if (data.list.length!=6){

                        meLoad.lock();
                        // 无数据
                        meLoad.noData();
                    }else{
                        meLoad.unlock();
                        meLoad.noData(false);
                        meLoad.resetload();
                    }



                }

            }

        })
    }
    function initList() {
        layer.open({type: 2,  shadeClose: false});

        $('.dropload-down').remove();
        // 每页展示4个
        var num = 4;
        var pageStart = 1,pageEnd = 0;
        // dropload
        meLoad =  $('#pro1').dropload({
            scrollArea : window,
            loadDownFn : function(me){

                $.ajax({
                    type:"post",
                    url:"/index/store/store_list",
                    data:jsonData,
                    success:function (data) {
                        layer.closeAll()
                        pageEnd = num * jsonData.counter;
                        pageStart = pageEnd - num;
                        if (data.list!=null){
                            let str=getList(data.list);
                            if (jsonData.counter==1 && data.list.length==0){
                                str='<img style="display: block; width: 2.82rem;margin: 37% auto;" src="/plan/caigou/img/wu.png">';

                                $("#pro1").html(str);
                            } else{
                                jsonData.counter++;
                                $("#pro1").append(str);
                            }

                            if (data.list.length!=6){
                                me.lock();
                                // 无数据
                                me.noData(true);
                            }else{

                                me.resetload();
                            }


                        }else{
                            me.lock();
                            // 无数据
                            me.noData();
                        }

                    },
                    error: function(xhr, type) {
                        me.lock();
                        // 无数据
                        me.noData();
                        me.resetload();
                    }
                })

            }
        });

    }
    function getList(data) {
        var str='';
        data.forEach(function (e,i) {
            str+='<li>\n' +
                '                <p>'+e.gname+'</p>\n' +
                '                <div class="date">\n' +
                '                    <span class="date_left">联系人：'+e.lxr+'</span>\n' +
                '                    <span class="date_left" style="margin-left: 0.45rem;">电话：'+e.mobile+'</span>\n' +
                '                </div>\n' +
                '        </li>';
        });
        return str;
    }
</script>
</body>
</html>
